﻿function Acceleration() {
    this.x=0.0;
    this.y=0.0;
    this.z=0.0;
};

function RotationRate() {
    this.alpha=0.0;
    this.beta=0.0;
    this.gamma=0.0;
};

// js receiver for the accelerometer
// from the phone, fires the devicemotion event
// as defined in http://www.w3.org/TR/orientation-event/
function wp7ExtensionsaccelerometerChanged(x, y, z, intervalms) {
    //here we create a fake deviceorientation event!
    var event = document.createEvent("Event");
    event.initEvent("devicemotion", true, true);
    event.acceleration = null;// new Acceleration();
    event.accelerationIncludingGravity = new Acceleration();
    event.accelerationIncludingGravity.x = parseFloat(x);
    event.accelerationIncludingGravity.y = parseFloat(y);
    event.accelerationIncludingGravity.z = parseFloat(z);
    event.rotationRate = null;//  new RotationRate();
    event.interval = parseInt(intervalms);
    window.dispatchEvent(event);
};

//Override of js alert method
function alert(message) {
    window.external.notify(message);
}